export type MailHandler<T> = (status: number, response: T, errMessage: string, info: string | null) => void

export type MailAllFetchHandler = (status: number, response: object | null, errMessage: string) => Promise<boolean>

export type SendMailHandler = (status: number, mailId: number, errMessage: string) => void


/**
 *   = ["outlook.com", "hotmail.com"
 , "gmail.cn", "163.com", "126.com",
 "qq.com", "live.com", "live.cn"]
 */
export enum MailVendor {
  QQ,
  ICLOUD,
  OUTLOOK,
  HOTMAIL,
  GMAIL,
  MAIL163,
  MAIL126,
  SINA,
  LIVE,
  YAHOO,
  OTHER,
  MailVendorCount
}

export function idStringForType(type: MailVendor) {
  switch (type) {
    case MailVendor.QQ:
      return "qq"
    case MailVendor.ICLOUD:
      return "icloud"
    case MailVendor.OUTLOOK:
      return "outlook"
    case MailVendor.HOTMAIL:
      return "hotmail"
    case MailVendor.SINA:
      return "sina"
    case MailVendor.GMAIL:
      return "gmail"
    case MailVendor.MAIL163:
      return "163"
    case MailVendor.MAIL126:
      return "126"
    case MailVendor.LIVE:
      return "live"
    case MailVendor.YAHOO:
    default:
      return "yahoo"
  }
}


export enum MailFetchProtocol {
  POP3 = "pop3",
  IMAP = "imap",
  COREMAIL = "coremail"
}

export function getFetchProtocolArray(): string[] {
  return ["pop3", "imap", "coremail"];
}

export enum MailSendProtocol {
  SMTP,
  COREMAIL
}

export enum SslType {
  None,
  SslTls,
  StartTls
}

export class MailInPutProtocol {
  host: string = ""
  port: number = 0
  sslType: number = 0
}